//
//  DataManager.h
//  leo
//
//  Created by 常艳 on 15/8/26.
//  Copyright (c) 2015年 mdx. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "DBHelper.h"
#import "User.h"
#import "Watch.h"
#import "Manager.h"
#import "Binder.h"
#import "Fence.h"
#import "Location.h"
#import "Contact.h"
#import "Tooler.h"
#import "Chat.h"
#import "Silent.h"
#import "Reminder.h"
#import "PMessage.h"
#import "Setting.h"
#import "Version.h"
#define DATAMANAGER_TAG @"DataManager---------------------"
@interface DataManager : NSObject
@property (nonatomic,strong) DBHelper *theHelper;
+(DataManager *)sharedSingleton;
//UI调用的API
-(Manager *)getManagerInfo:(NSString *)accountId deviceUid:(NSString *)deviceUid;//暂时没有用
//获取管理员列表
-(NSArray *)getManagerLists:(NSString *)deviceUid accountId:(NSString *)accountId;
//获取普通联系人列表
-(NSArray *)getContactLists:(NSString *)deviceUid accountId:(NSString *)accountId;
//返回当前选中手表的watch联系人
-(NSArray *)getWatchContacts:(NSString *)deviceUid role:(int)role;
// 获取SOS联系人列表
-(NSArray *)getSOSContactLists:(NSString *)deviceUid accountId:(NSString *)accountId;
//获取普通联系人列表，但是不包括手表的主管理员,用于添加SOS联系人时使用
-(NSArray *)getAddSOSContactLists:(NSString *)deviceUid accountId:(NSString *)accountId;
//获取指定管理员详细信息
-(Manager *)getManager:(NSString *)manager_id;//暂时没有使用
-(Manager *)getManagerByUid:(NSString *)user_id;
//获取指定联系人详细信息
-(Contact *)getContact:(NSString *)contact_id;
//获取当前账号绑定的所有手表列表
-(NSArray *)getWatchList:(NSString *)accountId;
-(NSArray *)getGroupWatchList:(int)groupId;
// 获取指定手表详细信息
-(Watch *)getWatch:(NSString *)deviceUid;
//获取指定手表的安全区域列表
-(NSArray *)getFenceList:(NSString *)deviceUid;
//获取指定安全区域相信信息
-(Fence *)getFence:(NSString *)fenceId;
//获取指定手表指定时间段的运动轨迹
-(NSArray *)getLocationList:(NSString *)deviceUid startTime:(NSString *)start endTime:(NSString *)end;
//获取指定手表最新位置信息
-(Location *)getLatestLocation:(NSString *)deviceUid;
//上拉加载数据
//读取家庭圈消息总数
-(int)getAllGroupChatNums:(int)groupId accountId:(NSString *)accountId;
//读取单聊消息总数
-(int)getAllSingleChatNums:(NSString *)parterId myId:(NSString *)myId;
//读取家庭圈未读消息数
-(int)getGroupChatNums:(int)groupId accountId:(NSString *)accountId;
//获取单聊未读消息数
-(int)getSingleChatNums:(NSString *)parterId myId:(NSString *)myId;
-(BOOL)setGroupChatRead:(int)groupId accountId:(NSString *)accountId;
-(BOOL)setSingleChatRead:(NSString *)partnerId accountId:(NSString *)accountId;
//读取家庭圈所有管理员，排除自己
-(NSArray *)getGroupManagers:(int )groupId accountId:(NSString *)accountId deviceUid:(NSString *)deviceUid;
//得到groupId
-(int)getGroupid:(NSString *)deviceUid accountId:(NSString *)accountId;
-(int)getWatchGroupid:(NSString *)deviceUid accountId:(NSString *)accountId;
//获取群聊聊天记录
-(NSArray *)getChatLists:(int)groupId accountId:(NSString *)accountId limit:(int)limit;
//获取单聊聊天记录
-(NSArray *)getSingleChatLists:(NSString *)partnerId myId:(NSString *)myId limit:(int)limit;
//根据user_id得到指定管理员详细信息
-(Manager *)gettheManager:(NSString *)uid accountId:(NSString *)accountId deviceUid:(NSString *)deviceUid;
//获取当前登录帐号
-(User *)getActiveUser;
//获取当前选中的手表
-(Watch *)getActiveWatch:(NSString *)accountId;
//设置手表状态
-(BOOL)updateWatchState:(NSString *)deviceUid;
//获取指定手表的静音时段列表
-(NSArray *)getSilentList:(NSString *)deviceUid;
//获取指定静音时段
-(Silent *)getSilent:(NSString *)silentId;
//获取指定手表的提醒列表
-(NSArray *)getReminderList:(NSString *)deviceUid;
//获取指定提醒
-(Reminder *)getReminder:(NSString *)reminderId;
-(NSArray *)getMessageList:(NSString *)accountId deviceUid:(NSString *)deviceUid;
-(BOOL)updateBindConfirm:(NSString *)msgId confirmValue:(int)confirmValue;
//SyncManager调用的API
-(BOOL)registerUser:(User *)user;
-(BOOL)updateUser:(User *)user;
-(BOOL)updateUserInfo:(User *)user;
-(BOOL)resetPwd:(NSString *)phoneNum password:(NSString *)password;
-(BOOL)addWatch:(Watch *)watch;
-(BOOL)updateWatchInfo:(Watch *)watch;
-(BOOL)addManager:(Manager *)manager;
-(BOOL)updateWatches:(NSArray *)watchLists;
-(BOOL)deleteManager:(Manager *)manager;
-(BOOL)updateManagers:(NSArray *)managerLists;
-(BOOL)updateContacts:(NSArray *)contactLists;
-(BOOL)unbindDevice:(NSString *)deviceUid uid:(NSString *)uid accountId:(NSString *)accountId;//暂时没有用
-(BOOL)updateLocateParameters:(NSString *)deviceUid reportInterval:(float)reportInterval sampleInterval:(float)sampleInterval;
-(BOOL)addFence:(Fence *)fence;
-(BOOL)updateFence:(Fence *)fence;
-(BOOL)updateFences:(NSArray *)fences;
-(BOOL)deleteFence:(NSString *)fenceId deviceUid:(NSString *)deviceUid;
-(long)getFenceId:(Fence *)fence;
-(BOOL)deleteFences:(NSArray *)fences;

-(BOOL)addPosition:(NSArray *)locArray;
-(NSString *)getlatestLocTime:(NSString *)deviceUid;
-(int)addLocation:(Location *)location;

-(BOOL)addContact:(Contact *)contact;
-(BOOL)deleteContact:(Contact *)contact;
//-(BOOL)updateManager:(Manager *)manager;
-(BOOL)addChat:(Chat *)chat;
-(BOOL)addPushChat:(Chat *)chat;
-(BOOL)updateChat:(Chat *)chat;
-(BOOL)addChats:(NSArray *)chatList;
-(NSString *)getseqId:(int) groupId;
-(NSString *)getseqIdSingle:(NSString *) targetUid;
-(BOOL)updateGroupChatFile:(NSString *)seqId filePath:(NSString *)filePath groupId:(NSString *)groupId;
-(BOOL)updateSingleChatFile:(NSString *)seqId filePath:(NSString *)filePath targetUid:(NSString *)targetUid;

-(BOOL)updateWatchPhoto:(NSString *)deviceUid filePath:(NSString *)filePath photoHash:(NSString *)photoHash;
//更新管理员头像信息
-(BOOL)updateManagerPhoto:(NSString *)user_id filePath:(NSString *)filePath photoHash:(NSString *)photoHash;
//更新联系人头像信息
-(BOOL)updateContactPhoto:(NSString *)phoneNum filePath:(NSString *)filePath photoHash:(NSString *)photoHash;

-(BOOL)addSilent:(Silent *)silent deviceUid:(NSString *)deviceUid;
-(BOOL)updateSilent:(Silent *)silent deviceUid:(NSString *)deviceUid;
-(BOOL)deleteSilent:(NSString *)silentId deviceUid:(NSString *)deviceUid;
-(BOOL)updateSilents:(NSArray *)silents deviceUid:(NSString *)deviceUid;
-(BOOL)IsSameSilent:(NSString *)deviceUid silent:(Silent *)silent isNew:(BOOL)isNew;

-(NSString *)getWatchTS:(NSString *)accountId;
-(NSString *)getEventTS:(NSString *)deviceUid;
-(NSString *)getManagerTS:(NSString *)deviceUid accountId:(NSString *)accountId;
//确定不需要之后再删除-(NSString *)getGroupManagerTS:(NSString *)groupId accountId:(NSString *)accountId;
-(NSString *)getContactTS:(NSString *)deviceUid accountId:(NSString *)accountId;
-(NSString *)getFenceTS:(NSString *)deviceUid;
-(NSString *)getRemindTs:(NSString *)deviceUid;
//读取手表photoHash
-(NSMutableDictionary *)getWatchPhotoHash;
//读取管理人员的photoHash
-(NSMutableDictionary *)getManagerPhotoHash:(NSString *)deviceUid;
//读取联系人的photoHash
-(NSMutableDictionary *)getContactPhotoHash:(NSString *)deviceUid;
-(BOOL)addReminder:(Reminder *)reminder deviceUid:(NSString *)deviceUid;
-(BOOL)updateReminder:(Reminder *)reminder deviceUid:(NSString *)deviceUid;
-(BOOL)deleteReminder:(NSString *)reminderId deviceUid:(NSString *)deviceUid;
-(BOOL)updateReminds:(NSArray *)reminders devieUid:(NSString *)deviceUid;
-(NSMutableDictionary *)getRemindAudioHash:(NSString *)deviceUid;
-(BOOL)updateRemindFile:(NSString *)reminderId filePath:(NSString *)filePath audioHash:(NSString *)audioHash;

-(BOOL)updateSetting:(Setting *)setting deviceUid:(NSString *)deviceUid;
-(BOOL)updateSettingArray:(NSArray *)settingArray deviceUid:(NSString *)deviceUid;
-(NSArray *)getMonthLocData:(int)year month:(int)month deviceUid:(NSString *)deviceUid;

-(BOOL)logoutUser:(User *)user;
-(BOOL)logoutOtherAccounts:(User *)user;
-(NSString *)getLatestSigleChatTime:(NSString *)targetUid accountId:(NSString *)accountId;
-(NSString *)getLatestGroupChatTime:(int)groupId accountId:(NSString *)accountId;

-(BOOL)updateRelation:(NSString *)deviceUid managerUid:(NSString *)managerUid alias:(NSString *)alias;

-(int)getUnReadNums:(NSString *)deviceUid groupId:(int)groupId accountId:(NSString *)accountId;
//确定不需要之后再删除-(NSArray *)getGroupLists:(NSString *)accountId;
//读取家庭圈所有副管理员，得到不同的user_id,群组策略修改
-(NSArray *)getDiffGroupManagers:(NSString *)groupId accountId:(NSString *)accountId;
//主管理员解除绑定
-(BOOL)adminUnbindDevice:(NSString *)deviceUid groupId:(NSString *)groupId accountId:(NSString *)accountId;
//副管理员解除绑定,绑定策略修改
-(BOOL)viceAdminUnbindDevice:(NSString *)userId groupId:(NSString *)groupId accountId:(NSString *)accountId;
-(BOOL)clearWatchData:(NSString *)deviceUid accountId:(NSString *)accountId;
-(BOOL)clearGroupWatchData:(NSString *)accountId groupId:(NSString *)groupId;
-(BOOL)updateViceAdminInfo:(Manager *)viceAdmin deviceUid:(NSString *)deviceUid;
-(BOOL)setChatRead:(NSString *)chatId;
-(BOOL)setSingleChatView:(NSString *)senderUid;
-(BOOL)setGroupChatView:(int)groupId;
-(BOOL)isChatRead:(NSString *)chatId;
-(BOOL)isChatSend:(NSString *)chatId;
-(BOOL)setWatchTheme:(int)watchTheme deviceUid:(NSString *)deviceUid;
-(NSArray *)getSendFailChats:(NSString *)accountId;
-(BOOL)IsSameContact:(NSString *)deviceUid contact:(Contact *)contact isNew:(BOOL)isNew;
-(BOOL)IsSameFence:(Fence *)fence isNew:(BOOL)isNew;
-(BOOL)isWatch:(NSString *)targetUid;
-(int)todayAssignTaskNum:(NSString *)deviceUid;
-(BOOL)updateWatchVersion:(Version *)version;
-(BOOL)updateVersionState:(NSString *)deviceUid;
-(NSArray *)getFailWhatchPhotoHash;
-(NSArray *)getFailManagerPhotoHash:(NSString *)deviceUid;
-(NSArray *)getFailContactPhotoHash:(NSString *)deviceUid;
@end

